package com.ztgf.order.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.ztgf.order.common.config.YmlConfig;
import com.ztgf.order.mapper.OrderAfterSaleLogMapper;
import com.ztgf.order.models.dto.OrderAfterSaleLogDTO;
import com.ztgf.order.models.service.IOrderAfterSaleLogService;
import com.ztgf.order.models.vo.OrderAfterSaleLogVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.scheduling.annotation.Async;

import javax.annotation.Resource;
import java.util.Date;

/**
 * author: chenyu.wang
 * date: 2020-07-06 11:41
 * Description:订单(退货换货)售后日志表控制器
 */
@DubboService
public class OrderAfterSaleLogServiceImpl extends ServiceImpl<OrderAfterSaleLogMapper, OrderAfterSaleLogDTO> implements IOrderAfterSaleLogService {

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(OrderAfterSaleLogDTO dto) {
        OrderAfterSaleLogDTO saveDto = new OrderAfterSaleLogDTO();
        saveDto.setAfterState(dto.getAfterState());
        saveDto.setOrderReturnCommodityId(dto.getOrderReturnCommodityId());
        saveDto.setId(ymlConfig.getPkId());
        saveDto.setCreateUserId(dto.getCreateUserId());
        saveDto.setProgressContent(dto.getProgressContent());
        return this.insert(saveDto);
    }

    /*
     * @description:查询售后订单进度跟踪，退换货表id
     * @author: chenyu.wang
     * @date: 2020-08-27
     */
    @Override
    public OrderAfterSaleLogVO querySchedule(Long id) {
        OrderAfterSaleLogVO orderAfterSaleLogVO = baseMapper.queryAfterOrderMsg(id);
        orderAfterSaleLogVO.setList(baseMapper.queryLogDetails(id));
        return orderAfterSaleLogVO;
    }
}
